﻿/******************************************************************************
 * 【本类功能概述】                                 					      *
 *  版权所有（C）2017-20XX，梦匠科技                                          *
 *  保留所有权利。                                                            *
 ******************************************************************************
 *  作者 : <PC-shijiankai>
 *****************************************************************************/
using UnityEngine;
using System.Collections.Generic;
namespace CSV
{
/// <summary>
/// 配置表名字
/// </summary>
public class Configuration
{
	private volatile static CSVReader _instance = null;
    private static readonly object lockHelper = new object();
	/// <summary>
	/// 配置表名字
	/// </summary>
	public const string _id="id";
	/// <summary>
	/// 浮点型
	/// </summary>
	public const string _HP="HP";
	/// <summary>
	/// 字符串
	/// </summary>
	public const string _name="name";
	/// <summary>
	/// 2个浮点数字
	/// </summary>
	public const string _camera_location="camera_location";
	/// <summary>
	/// 3个浮点数字
	/// </summary>
	public const string _camera_locationa="camera_locationa";

	public class line
    {
		/// <summary>
		/// 配置表名字
		/// </summary>
		public int id;
		/// <summary>
		/// 浮点型
		/// </summary>
		public float HP;
		/// <summary>
		/// 字符串
		/// </summary>
		public string name;
		/// <summary>
		/// 2个浮点数字
		/// </summary>
		public Vector2 camera_location;
		/// <summary>
		/// 3个浮点数字
		/// </summary>
		public Vector3 camera_locationa;

    }
    private static Dictionary<string, line> m_datadic = new Dictionary<string, line>();
    public static line getline(string id)
    {
        if (m_datadic.ContainsKey(id))
        {
            return m_datadic[id];
        }
        else
        {
            line _line = new line();
			_line.id = Instance().getintById(id, _id);
			_line.HP = Instance().getfloatById(id, _HP);
			_line.name = Instance().getstringById(id, _name);
			_line.camera_location = Instance().getVector2ById(id, _camera_location);
			_line.camera_locationa = Instance().getVector3ById(id, _camera_locationa);

            m_datadic.Add(id, _line);
            return _line;
        }
    }
	
	public static CSVReader Instance()
	{
        if(_instance == null)
        {
            lock(lockHelper)
            {
                if(_instance == null)
                     _instance = ConfigManager.GetCsvData("Configuration");
            }
        }
        return _instance;
    }
}
}